<#include "../header.ftl" />
<@head title="评论管理" />
<#import "/META-INF/mspring.ftl" as mspring />
		<@side.sidenav active="评论管理"/>
	    <div class="g-content">
	        <div class="g-content-container">
	            <div class="g-p">
					<div class="m-crumb">
					    <ul class="f-cb">
					        <li><i>&gt;</i><a href="${spaceUrl}/admin">博客管理</a></li>
					        <li><i>&gt;</i><a href="javascript:void(0);">评论管理</a></li>
					    </ul>
					</div>
					<div class="page-title">
						<h1>评论管理</h1>
					</div>
					<div class="m-content">
						<form name="commentForm" id="commentForm" action="${spaceUrl}/admin/comment/list" method="GET">
							<@spring.bind "commentPage" />
							<!-- pagination parameter -->
							<@spring.formHiddenInput path="commentPage.pageNo" />
							<@spring.formHiddenInput path="commentPage.totalPages" />
							<@spring.formHiddenInput path="commentPage.totalCount" />
							<!-- sorter parameter -->
							<@spring.formHiddenInput path="commentPage.sortEnable" />
							<@spring.formHiddenInput path="commentPage.sort.field" />
							<@spring.formHiddenInput path="commentPage.sort.order" />
							
					    	<#if (commentPage?exists && commentPage.result?size > 0)>
					    		<div id="medias" class="sep">
						        	<#list commentPage.result as comment>
						        		<div class="media">
						        			<a href="#" class="media-cap"><img src="<@avatar avatar=comment.author.smallAvatar />" class="img-radius"></a>
						        			<div class="media-body">
						        				<div class="media-body-title">
						        					<strong><a href="<@UserSpaceUrl name=comment.author.name />" target="_blank">${comment.author.alias}</a>：</strong>
						        					<small class="pull-right">
						        						${comment.createTime}
						        						<a href="javascript:d(${comment.id}, '${comment.author.alias}');">回复</a>
						        						<a href="javascript:deleteComment(${comment.id});">删除</a>
						        					</small>
						        				</div>
						        				<p class="typo-p">
						        					${comment.content}
						        				</p>
						        			</div>
						        		</div>
							    	</#list>
						    	</div>
						    <#else>
						    	<a class="listpub" href="javascript:void(0);" class="sep"><i class="icon-plus"></i><span>&nbsp;暂无评论</span></a>
				        	</#if>
						    <#if (commentPage.totalPages > 1)>
		                        <@space.pagenavi pageEntity=commentPage baseUrl=spaceUrl + "/admin/comment/list?pageNo=$page$" />
		                    </#if>
						</form>
					</div>
	            </div>
	        </div>
	    </div>
	    <script type="text/javascript" src="${base}/script/lhgdialog/lhgdialog.min.js?self=true&skin=discuz"></script>
	    <script type="text/javascript" src="${base}/script/mlog.dialog.js"></script>
	    <script type="text/javascript">
	    	function d(id, author){
	    		mlog.dialog.showModelDialog({
	    			title : '回复 ' + author,
	    			width : 400,
	    			height: 200,
	    			fixed : true,
	    			min : false,
	    			max : false,
	    			padding : '0',
	    			content : 'url:${spaceUrl}/admin/comment/reply?id=' + id
	    		});
	    	}
	    	function deleteComment(id){
	    		if(!id){
	    			return;
	    		}
	    		if(!confirm('确认删除该条评论吗？')){
	    			return;
	    		}
	    		$.post('${spaceUrl}/admin/comment/delete?id=' + id, function(response){
	    			if(response.success){
	    				var pageNo = $('#pageNo').val();
		    			var url = '${spaceUrl}/admin/comment/list';
		    			if(pageNo){
		    				url = url + '?pageNo=' + pageNo;
		    			}
		    			window.location.href = url;
	    			}
	    			else{
	    				alert('评论删除失败。' + response.message);
	    			}
	    		});
	    	}
	    </script>
<#include "../footer.ftl" />